﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LSData;
using LSEntity;
using LSUtility;

namespace LSBLL
{
    public static class QuestionBLL
    {
        public static List<QuestionType> QuestionTypeForOTGetList(int testId)
        {
            return QuestionData.QuestionTypeForOTGetList(testId);
        }

        public static List<QuestionForOT> QuestionForOTGetList(int examId)
        {
            return QuestionData.QuestionForOTGetList(examId);
        }

        public static List<List<QuestionForOT>> QuestionForOTListSetGroup(this List<QuestionForOT> sources)
        {
            var result = new List<List<QuestionForOT>>();
            var group = new List<QuestionForOT>();
            var count = sources.ListGetCount();
            for (var i = 0; i < count; i++)
            {
                if (sources[i].SubQuestionFlag == 0)
                {
                    group = new List<QuestionForOT> { sources[i] };
                }
                else
                {
                    group.Add(sources[i]);
                }

                if (count <= i + 1 || sources[i + 1].SubQuestionFlag == 0)
                {
                    result.Add(group);
                }
            }
            return result;
        }

        public static string QuestionTypeGetDescription(int questionTypeId, int curriculumId, int onlineOrPrint = 0)
        {
            return QuestionData.QuestionTypeGetDescription(questionTypeId, curriculumId, onlineOrPrint);
        }
    }
}
